<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Помощник партнерок видео парсеров
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */

/**
 * Получение информации по видео партнерке
 *
 * @access public
 * @param string $output
 * @return string
 */
function get_video_partner_info($name) {
    $obj =& get_instance();
    $use_partner = $obj->variables->get('use_' . $name);
    if (false !== $use_partner) {
        $partner_id = $obj->variables->get($name . '_id');
        $partner_shop = $obj->variables->get($name . '_shop');
        $info = array(
            'id' => $partner_id,
            'shop' => $partner_shop,
            'use' => 'yes' == $use_partner,
            'xml_link' => '',
            'video_link' => ''
        );
        $update_func = 'update_' . $name . '_info';
        if (is_callable($update_func)) {
            $info = call_user_func($update_func, $info);
        }
        return $info;
    }
    return false;
}

/**
 * Update kinoperez info
 * @param $info
 */
function update_kinoperez_info($info) {
    $info['xml_link'] = 'http://kinoperez.ru/getxml.php';
    $info['video_link'] = 'http://' . $info['shop'] . '/movie/[EXTERNAL_ID].html?aid=' . $info['id'];
    return $info;
}

/**
 * Update dircash info
 * @param $info
 */
function update_dircash_info($info) {
    $info['xml_link'] = 'http://dircash.com/xml.php?wmid=' . $info['id'];
    $info['video_link'] = 'http://' . $info['shop'] . '/' . $info['id'] . '/download/[EXTERNAL_ID]/';
    return $info;
}

/**
 * Update loadpartners info
 * @param $info
 */
function update_loadpartners_info($info) {
    $info['xml_link'] = 'http://kinoloads.com/bd.php?pid=' . $info['id'] . '&full=1';
    $info['video_link'] = 'http://' . $info['shop'] . '/link-' . $info['id'] . '-1-[EXTERNAL_ID]';
    return $info;
}

